package com.ruoyi.web.controller.nysjwh;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nysjwh.domain.TbNysjwhYbgh;
import com.ruoyi.nysjwh.service.ITbNysjwhYbghService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仪表更换Controller
 * 
 * @author hc
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/nysjwh/ybgh")
public class TbNysjwhYbghController extends BaseController
{
    @Autowired
    private ITbNysjwhYbghService tbNysjwhYbghService;

    /**
     * 查询仪表更换列表
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbNysjwhYbgh tbNysjwhYbgh)
    {
        startPage();
        List<TbNysjwhYbgh> list = tbNysjwhYbghService.selectTbNysjwhYbghList(tbNysjwhYbgh);
        return getDataTable(list);
    }

    /**
     * 导出仪表更换列表
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:export')")
    @Log(title = "仪表更换", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbNysjwhYbgh tbNysjwhYbgh)
    {
        List<TbNysjwhYbgh> list = tbNysjwhYbghService.selectTbNysjwhYbghList(tbNysjwhYbgh);
        ExcelUtil<TbNysjwhYbgh> util = new ExcelUtil<TbNysjwhYbgh>(TbNysjwhYbgh.class);
        util.exportExcel(response, list, "仪表更换数据");
    }

    /**
     * 获取仪表更换详细信息
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbNysjwhYbghService.selectTbNysjwhYbghById(id));
    }

    /**
     * 新增仪表更换
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:add')")
    @Log(title = "仪表更换", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbNysjwhYbgh tbNysjwhYbgh)
    {
        return toAjax(tbNysjwhYbghService.insertTbNysjwhYbgh(tbNysjwhYbgh));
    }

    /**
     * 修改仪表更换
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:edit')")
    @Log(title = "仪表更换", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbNysjwhYbgh tbNysjwhYbgh)
    {
        return toAjax(tbNysjwhYbghService.updateTbNysjwhYbgh(tbNysjwhYbgh));
    }

    /**
     * 删除仪表更换
     */
    @PreAuthorize("@ss.hasPermi('nysjwh:ybgh:remove')")
    @Log(title = "仪表更换", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbNysjwhYbghService.deleteTbNysjwhYbghByIds(ids));
    }
}
